
#include "gui_scene.h"
#include <sstream>

using namespace WtfGui;
using namespace WtfEngine;

void Scene::Update() {
	Renderer::GetInstance().Render(mrScene, mrCamera);
};

void Scene::Paint(float d) {
	glTranslated(0, -getRealSize()[1], 0);
	glColor4f(1.0, 1.0, 1.0, 1.0);

	mrScene->Draw(getRealSize());
};

void Scene::OnResize() {
	mrScene = new FBOTexture();
	mrScene->Create(getSize()[0], getSize()[1]);
};

void Scene::Destroy() {
	if(mbUpdate) IDynamic::Destroy();
	//Widget::Destroy();
};


SceneDiagnostics::SceneDiagnostics():
Window("Scene Diagnostics") {
	mrLblFPS = new Widgets::Label("FPS: ");
	AddChild(mrLblFPS);

	Resize(200, 100);
	IDynamic::Init();
};

void SceneDiagnostics::Update() {
	std::ostringstream	s;

	s << (1.0 / Kernel::GetInstance().GetGameStatePtr()->GetDelta());
	mrLblFPS->setCaption(String("FPS: ") + s.str());
};

void SceneDiagnostics::OnResize() {
	mrLblFPS->Resize(getInnerSize());
	Window::OnResize();
};
